function random(m, n) {
    return m + Math.ceil(Math.random() * (n - m + 1)) - 1
}
// (function () {
//     setTimeout(() => {
//         if (random(1, 100) <= 50) {
//             console.log('success')
//             return
//         }
//         console.log('failed')
//     }, 500)
// })()
const promise = new Promise((resolve, reject) => {
    setTimeout(() => {
        let num = random(1, 100) 
        if (num <= 50) {
            resolve(num) // 将对象状态修改为成功
        } else {
            reject(num) // 将对象状态修改为失败
        }
    }, 500)
})
promise.then((value) => {
    console.log('success：'+value)
}, (reason) => {
    console.log('failed：'+reason)
})
console.log(promise)

new Promise((resolve)=>{
    console.log(111)
    resolve(1)
}).then(()=>{
    console.log(222)
})
console.log(333)

